<form id="form" class="layui-form" action="{:url()}" method="post">
    <input type="hidden" name="id" value="{$data['id']}">

    <div class="layui-form-item">
        <label class="layui-form-label">选择位置</label>
        <div class="layui-input-inline">
            <select name="position_id">
                <option value="0">请选择</option>
                {volist name="positionList" id="item"}
                <option value="{$item['id']}" {if $data['position_id'] == $item['id']}selected{/if}>{$item['title']}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" value="{$data['title']}" class="layui-input" placeholder="必填">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">展示图</label>
        <div class="layui-input-inline">
            <div class="ybUploadFile" data-name="img" data-value="{$data['img']}"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">跳转链接</label>
        <div class="layui-input-inline">
            <input type="text" name="link_url" value="{$data['link_url']}" class="layui-input" placeholder="请参考前端页面地址">
        </div>
        <div class="layui-form-mid layui-word-aux">注：不填-不跳转；detail-当前详情；其他-请参考前端页面连接</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">展示时间</label>
        <div class="layui-input-inline">
            <input type="text" id="start_time" name="start_time" value="{$data['start_time']}" class="layui-input" placeholder="" readonly>
        </div>
        <div class="layui-form-mid layui-word-aux"> - </div>
        <div class="layui-input-inline">
            <input type="text" id="end_time" name="end_time" value="{$data['end_time']}" class="layui-input" placeholder="" readonly>
        </div>
        <div class="layui-form-mid layui-word-aux">不填则不限制</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="text" name="sort" value="{$data['sort']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="展示" {if $data['status'] == 1}checked{/if}>
            <input type="radio" name="status" value="0" title="不展示" {if $data['status'] == 0}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">详情</label>
        <div class="layui-input-block">
            <div class="ybUEditor" data-name="body" data-value="{$data['body']}"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn submitForm" formId="form">提交</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    $(function(){
        var currentLayerIndex = parent.ybLayer.getFrameIndex(window.name);

        //日期
        ybLaydate.render({
            elem: '#start_time'
            ,type: 'datetime'
        });
        ybLaydate.render({
            elem: '#end_time'
            ,type: 'datetime'
        });

        $('.submitForm').click(function (evt) {
            formPost(evt, $(this), function (res) {
                ybLayer.msg(res.msg,{icon: 6});
                setTimeout(function () {
                    parent.ybLayer.close(currentLayerIndex);
                    parent.ybTable.reload('mytable');
                }, 1000);
            }, function (res) {
                ybLayer.msg(res.msg, {icon: 5});
            });
            return false;
        });
    });
</script>